package com.atom.app.mvi.db

import android.annotation.SuppressLint
import androidx.room.TypeConverter
import java.text.SimpleDateFormat
import java.util.*

class DateToStringConverter {
    @SuppressLint("SimpleDateFormat")
    private val format: SimpleDateFormat = SimpleDateFormat(
        "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
        Locale.US
    )

    @TypeConverter
    fun stringToDate(value: String?): Date? {
        return value?.let { format.parse(it) }
    }

    @TypeConverter
    fun dataToString(value: Date?): String? {
        return value?.let { format.format(it) }
    }
}
